﻿<template>
    <full-screen-dialog
        :title="titleMap[mode]"
        v-model="visible"
        :width="600"
        destroy-on-close
        :close-on-click-modal="false"
        :before-close="handleBeforeClose"
    >
        <el-form
            :model="entityObj"
            :rules="rules"
            :disabled="mode == 'Show'"
            ref="dialogForm"
            label-width="100px"
        >
        <el-card >
            <template #header>
            <div class="card-header">
                <span>银行账户</span>
            </div>
            </template>
            
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="单位名称" prop="companyName">
                        <el-input v-model="entityObj.companyName" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="纳税人识别号" prop="taxNumber">
                        <el-input v-model="entityObj.taxNumber" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="联系地址" prop="address">
                        <el-input v-model="entityObj.address" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>

           
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="开户行" prop="openBank">
                        <el-input v-model="entityObj.openBank" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="银行账户" prop="bankAccount">
                        <el-input v-model="entityObj.bankAccount" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="联系人" prop="contacts">
                        <el-input v-model="entityObj.contacts" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="22">
                    <el-form-item label-width="120px" label="电话号码" prop="tel">
                        <el-input v-model="entityObj.tel" type="text" style="width: 100%"/>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-card>
            
           
        </el-form>
        <template #footer>
            <el-button @click="handleBeforeClose">取 消</el-button>
            <el-button
                v-if="mode != 'show'"
                type="primary"
                :loading="isSaveing"
                @click="submit()"
            >确 定</el-button>
        </template>

        
    </full-screen-dialog>
</template>



<script>
import tool from "@/utils/tool";
export default {
    emits: ["success", "closed"],
    data() {
        return {
            mode: "Add",
            titleMap: {
                Add: "新增",
                Edit: "设置开票信息",
                Show: "查看",
            },
            entityObj: {
                supplierIds:[],
                suppliers: [],
            },
            supplierState: false,
            applyOrderState: false,
            storeState: false,
            queryList: {},
            visible: false,
            isSaveing: false,
            needSaveFlag: false,
            //验证规则
            rules: {},
            purchaseUnityId:0,
           
        };
    },
    
    methods: {
        //显示=
        async open(mode = "Add") {
            this.mode = mode;
            this.visible = true;
            return this;
        },
        //表单提交方法
        submit() {
            this.$refs.dialogForm.validate(async (valid) => {
                if (valid) {
                    this.isSaveing = true;
                    try {
                        this.entityObj.PurchaseUnityId=this.purchaseUnityId;
                        var returnValue =
                            await this.$API.auth.PostProcessApi.post(
                                "invoiceInfo/updateInvoiceInfo",
                                { ...this.entityObj }
                            );
                        if (returnValue.status == 200) {
                            this.$message.success("操作成功");
                            this.$emit("fatherMethod");
                            this.isSaveing = false;
                            this.visible = false;
                        } else {
                            this.$message.error("操作失败:" + returnValue.msg);
                            this.isSaveing = false;
                        }
                    } catch (error) {
                        this.loading = false;
                        this.isSaveing = false;
                        return false;
                    }
                }
            });
        },
        //表单注入数据
        async setData(data) {
            console.log(data)
            this.purchaseUnityId=data.purchaseUnityId;
            const returnValue = await this.$API.auth.GetProcessApi.get(
                `invoiceInfo/${data.purchaseUnityId}/purchaseUnity`,{}
            );
            if (returnValue.status == 200) { 
                this.entityObj = {
                    ...returnValue.response,
                };
            }
        },
    },
    async mounted() {
    },
};
</script>

<style></style>
